package com.example.seckill.Config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import org.springframework.amqp.core.Queue;

/*主题模式*/
@Configuration
public class RabbitMQTopicConfig {

    private  static  final String QUEUE="seckillQueue";


    private  static  final String EXCHANGE="seckillExchange";

    private static final String ROUTINGKEY="seckill.#";

    //队列
    @Bean
    public Queue queue(){
        return new Queue(QUEUE);

    }
    //交换机R
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(EXCHANGE);
    }
    //绑定
    @Bean
    public Binding binding(){
        return BindingBuilder.bind(queue()).to(topicExchange()).with(ROUTINGKEY);
    }
}
